const msg = (title, content, btCancel, done, cancel) =>{

    if(title && !content) {
        content = title;
        title = '系统信息';
    }

    btCancel = btCancel || false;
    wx.showModal({
        title: title,
        content: content,
        showCancel: btCancel,
        success (res) {
          if (res.confirm) {
            console.log('用户点击确定')
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
    });   
}

const error = (title, content) => {
    if(title && !content) {
        content = title;
        title = '系统信息';
    }
    
    wx.showModal({
        title: title,
        content: content,
        showCancel: false,
    }); 
}

const input = (title, placeholder, done) => {
    wx.showModal({
        title: title,
        placeholderText: placeholder,
        editable: true,
        success: (res)=>{
            if(res.confirm) {
                if(done) done.call(res, res.content);
            }
        }
    }); 
}

module.exports = {
    msg,
    error,
    input
  }
  